package com.tjetc.view.impl;

import com.tjetc.constant.CommonConstant;
import com.tjetc.exception.MessageException;
import com.tjetc.pojo.dto.HistoryDTO;
import com.tjetc.utils.ScannerUtils;
import com.tjetc.view.HistoryPage;

/**
 * @Author: itda
 * @Date: 2024/5/17 10:08
 * @Description: HistoryPageImpl
 */
public class HistoryPageImpl implements HistoryPage {
    @Override
    public HistoryDTO show() {
        while (true) {
            System.out.println("1.预约订单");
            System.out.println("2.历史订单");
            System.out.println("3.返回");
            System.out.println("请输入:");
            int option = ScannerUtils.sc.nextInt();
            if (option<1||option>3){
                try {
                    throw new MessageException(CommonConstant.COMMAND_ERROR);
                } catch (MessageException e) {
                    System.out.println(e.getMessage());
                }
            }
            return HistoryDTO.builder().option(option).build();
        }
    }
}
